﻿package app.view 
{
	import app.ApplicationFacade;
	import app.model.vo.SectionVO;
	import app.view.BaseMediator;
	import app.view.events.UIEvent;
	import app.view.managers.SectionsManager;
	import org.puremvc.interfaces.INotification;
	
	/**
	 * Медиатор для заголовка
	 * @author firsoff maxim, snzflash.com, tel: +79222345364, skype: maxim.firsoff
	 */
	public class HeaderMediator extends BaseMediator
	{
		public static const NAME:String = "HeaderMediator";
		
		public function HeaderMediator(viewComponent:Object = null) 
		{
			super(NAME, viewComponent);
			header.addEventListener (UIEvent.LANG_CHANGE, onLangChange);
		};
		
		private function onLangChange(event:UIEvent):void 
		{
			sendNotification ( ApplicationFacade.CMD_CHANGE_LANG, event.data );
		};
		
		override public function listNotificationInterests():Array 
		{
			return [ApplicationFacade.CHANGE_SECTION];
		};
		
		override public function handleNotification(notification:INotification):void 
		{
			super.handleNotification(notification);
			switch ( notification.getName() ) 
            {  
				case ApplicationFacade.CHANGE_SECTION:
					header.sectionID = ( notification.getBody() as SectionVO).id;
				break;
            };
		};
		
		public function get header():Header { return viewComponent as Header; };
	};
};